{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "11535a8c",
   "metadata": {},
   "source": [
    "## 课程表的制作\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c6f1c4ff",
   "metadata": {},
   "source": [
    "### 第一次更新"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7aacc480",
   "metadata": {},
   "source": [
    "#### 存在的问题\n",
    "* 1、时间区间\n",
    "* 2、整个代码不能循环运作（非死循环）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d46c2ae7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入学生用户liuqitao\n",
      "请输入用户密码09202590\n",
      "登录成功，欢迎 liuqitao 使用\n",
      "半个小时内没课\n"
     ]
    }
   ],
   "source": [
    "### 登录课程表主页\n",
    "\n",
    "# 录入数据需要用到的学生信息\n",
    "user_data = (\"liuqitao\")\n",
    "password_data =(\"09202590\")\n",
    "\n",
    "# 制作登录界面\n",
    "# 使用 while True 并以 break 进行停止\n",
    "# 设置输入次数为3次\n",
    "count = 3\n",
    "while True : \n",
    "    count -= 1\n",
    "    username = input(\"请输入学生用户：\")\n",
    "    password = input(\"请输入用户密码：\")\n",
    "    if username == user_data:\n",
    "        if password == password_data:\n",
    "            print (\"登录成功，欢迎\",user_data,\"使用！\")\n",
    "            break        \n",
    "        else :\n",
    "            print (\"账号或密码输入错误！请重新输入，您还有\",count,\"次尝试的机会\")\n",
    "    else :\n",
    "        print (\"账号或密码输入错误！请重新输入，您还有\",count,\"次尝试的机会\")\n",
    "    if count == -1:\n",
    "        print(\"尝试次数过多，请10分钟以后在尝试\")\n",
    "        break\n",
    "import time \n",
    "#from itertools import repeat\n",
    "right_time = time.strftime(\"%A %H:%M\")#格式化时间\n",
    "# 设置了提前半个钟（注：Hah == Half an hour）\n",
    "Hah_Mon_class = ('Monday 10:05')\n",
    "Han_Mon_class = ('Monday 14:00')\n",
    "Hah_Tue_class = ('Tuesday 14:00')\n",
    "Hah_Wes_class = ('Wednesday 18:15')\n",
    "Hah_Thu_class = ('Thursday 15:40')\n",
    "Hah_Fri_class = ('Friday 10:05')\n",
    "#for _ in repeat(None):\n",
    "while True:\n",
    "    if Hah_Mon_class in right_time:\n",
    "        print (\"距离羽毛球课还有半个小时\")\n",
    "    elif Hah_Mon_class in right_time:\n",
    "        print (\"距离python语言课还有半个小时\")\n",
    "    elif Hah_Tue_class in right_time:\n",
    "        print (\"距离H5互动技术与应用课还有半个小时\")\n",
    "    elif Hah_Wes_class in right_time:\n",
    "        print (\"距离创业基础（实践）课还有半个小时\")\n",
    "    elif Hah_Thu_class in right_time: \n",
    "        print(\"距离大学英语（三）还有半个小时\")\n",
    "    elif Hah_Fri_class in right_time:\n",
    "        print(\"距离illustrato软件应用课还有半个小时\")\n",
    "    else :\n",
    "        print (\"半个小时内没课\")\n",
    "    break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2ab0b9bd",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "ac2ff6a0",
   "metadata": {},
   "source": [
    "### 第二次更新"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ff3122bb",
   "metadata": {},
   "source": [
    "> 更新的内容\n",
    "  >* 1.解决了时间区间的设置问题\n",
    "  >* 2.增加了普通用户和VIP用户的登录\n",
    "  >* 3.增加了用户输入\n",
    "  >* 4.完善了课程表输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7ecea644",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "---------课程表用户登录界面---------\n",
      "\n",
      "请输入正确的账号：lqt\n",
      "请输入正确的密码：lqt\n",
      "登录成功，欢迎 lqt 使用！\n",
      "\n",
      "---------课程表查询界面---------\n",
      "\n",
      "尊贵的VIP用户，您今天还剩 10 次查询机会\n",
      "尊贵的VIP用户，是否要查询当前课程表，是 请回复“T”，否 请回复“F”\n",
      "您的选择是：T\n",
      "\n",
      "尊贵的VIP用户，请输入您要查询的星期（一~七）：三\n",
      "现在的时间是 Sunday  19:46\n",
      "(18:45 - 20:55) 创业基础（实践）@1-205\n",
      "尊贵的VIP用户，您今天还剩 9 次查询机会\n",
      "\n",
      "尊贵的VIP用户，是否要查询当前课程表，是 请回复“T”，否 请回复“F”\n",
      "您的选择是：F\n",
      "尊贵的VIP用户，感谢你的使用！\n"
     ]
    }
   ],
   "source": [
    "# 由于是 VIP 的原因，故下列代码中，对于普通用户 只有自动获取时间以及输出课程表的操作\n",
    "# 而对于 VIP 用户 则拥有个性化设置，能够根据输入的星期来输出课表 （即 用户交互）\n",
    "\n",
    "\n",
    "# 普通用户信息输入\n",
    "user_data = [\"123\",\"234\",\"345\"]\n",
    "password_data = [\"123\",\"234\",\"345\"]\n",
    "# VIP用户信息输入\n",
    "vipuser_data = [\"Kanekikeh\",\"lqt\"]\n",
    "vippassword_data = [\"Kanekikeh\",\"lqt\"]\n",
    "\n",
    "info_01 = '''---------课程表用户登录界面---------'''\n",
    "print(info_01)\n",
    "print()\n",
    "\n",
    "\n",
    "count = 3\n",
    "while True:\n",
    "    count -= 1\n",
    "    username = input(\"请输入正确的账号：\")\n",
    "    password = input(\"请输入正确的密码：\")\n",
    "    if username in user_data or username in vipuser_data: # 查询账号是否正确\n",
    "        if password in password_data or password in vippassword_data: # 查询密码是否正确\n",
    "            print(\"登录成功，欢迎 %s 使用！\" %(username))\n",
    "            break\n",
    "        else: #密码错误\n",
    "            print(\"账号或密码输入错误！请重新输入，您还有\",count,\"次输入机会！\")\n",
    "    else: # 账号错误\n",
    "        print(\"账号或密码输入错误！请重新输入，您还有\",count,\"次输入机会！\")\n",
    "    if count == 0:\n",
    "        print(\"尝试次数过多，请5分钟以后再重新尝试！\")\n",
    "        break\n",
    "        \n",
    "print()\n",
    "\n",
    "info_02 = '''---------课程表查询界面---------'''\n",
    "print(info_02)\n",
    "\n",
    "print()\n",
    "\n",
    "# 设置普通用户和VIP用户的查询次数\n",
    "user_count = 5\n",
    "vipuser_count = 10\n",
    "\n",
    "if username in user_data:  # 判断普通用户的查询次数\n",
    "    print (\"亲爱的用户，您今天还剩\",user_count,\"次查询机会\")\n",
    "    while True:\n",
    "        user_count -= 1\n",
    "        if user_count == -1:\n",
    "            print(\"亲爱的用户，您今天的查询次数已使用完，请明天再来，谢谢使用！\")\n",
    "            break\n",
    "        else:\n",
    "            print(\"请输入是否要查询课程，是 回复 “1”，否 回复 “2” \")\n",
    "            user_choice = int(input(\"请输入你的选择\"))\n",
    "            if user_choice == 1:\n",
    "                print()\n",
    "                import time \n",
    "                # 格式化时间\n",
    "                today = time.strftime(\"%A\")\n",
    "                right_time = int(time.strftime(\"%H%M\")) # 这个用于后端页面\n",
    "                now = time.strftime(\"%A  %H:%M\") #这个用于前端页面\n",
    "                # 设置了提前半个钟（注：Hah == Half an hour）\n",
    "                Hah_Mon_class = int(('1035'))\n",
    "                Han_Mon_class = int(('1430'))\n",
    "                Hah_Tue_class = int(('1430'))\n",
    "                Hah_Wes_class = int(('1845'))\n",
    "                Hah_Thu_class = int(('1610'))\n",
    "                Hah_Fri_class = int(('1035'))\n",
    "                while True:\n",
    "                    if today == \"Monday\":\n",
    "                        if  1005< right_time < 1035:\n",
    "                            print (\"现在的时间是\",now)\n",
    "                            print(\"距离羽毛球课还有\",Hah_Mon_class - right_time,\"分钟！\")\n",
    "                            print(\"亲爱的用户，您今天还剩\",user_count,\"次查询机会\")\n",
    "\n",
    "                    elif today == \"Monday\":\n",
    "                        if 1400 < right_time < 1430:\n",
    "                            print (\"现在的时间是\",now)\n",
    "                            print(\"距离 Python 课还有\",Hah_Mon_class - right_time,\"分钟！\")\n",
    "                            print(\"亲爱的用户，您今天还剩\",user_count,\"次查询机会\")\n",
    "                        \n",
    "\n",
    "                    elif today == \"Tuesday\":\n",
    "                        if 1400 < right_time < 1430:\n",
    "                            print(\"现在的时间是\",now)\n",
    "                            print(\"距离H5互动技术与应用课还有\",Hah_Mon_class - right_time,\"分钟！\")\n",
    "                            print(\"亲爱的用户，您今天还剩\",user_count,\"次查询机会\")\n",
    "\n",
    "                    elif today == \"Wednesday\":\n",
    "                        if 1815 < right_time < 1845:\n",
    "                            print(\"现在的时间是\",now)\n",
    "                            print(\"距离创业基础（实践）课还有\",Hah_Mon_class - right_time,\"分钟！\")\n",
    "                            print(\"亲爱的用户，您今天还剩\",user_count,\"次查询机会\")\n",
    "\n",
    "                    elif today == \"Thursday\":\n",
    "                        if 1545 < right_time < 1610:\n",
    "                            print(\"现在的时间是\",now)\n",
    "                            print(\"距离大学英语（三）还有\",Hah_Mon_class - right_time,\"分钟！\")\n",
    "                            print(\"亲爱的用户，您今天还剩\",user_count,\"次查询机会\")\n",
    "\n",
    "                    elif today == \"Friday\":\n",
    "                        if 1005 < right_time < 1035:\n",
    "                            print(\"现在的时间是\",now)\n",
    "                            print(\"距离illustrato软件应用课还有\",Hah_Mon_class - right_time,\"分钟！\")\n",
    "                            print(\"亲爱的用户，您今天还剩\",user_count,\"次查询机会\")\n",
    "                            \n",
    "                    elif today == \"Saturday\":\n",
    "                        print(\"现在的时间是\",now)\n",
    "                        print(\"亲爱的用户，今天是周末！\")\n",
    "                        print(\"亲爱的用户，您今天还剩\",user_count,\"次查询机会\")\n",
    "                    elif today == \"Sunday\":\n",
    "                        print(\"现在的时间是\",now)\n",
    "                        print(\"亲爱的用户，今天是周末\")\n",
    "                        print(\"亲爱的用户，您今天还剩\",user_count,\"次查询机会\")\n",
    "                    else :\n",
    "                        print (\"现在的时间是\",now)\n",
    "                        print (\"半个小时内没课\")\n",
    "                        print(\"亲爱的用户，您今天还剩\",user_count,\"次查询机会\")\n",
    "                        \n",
    "                    break\n",
    "            else :\n",
    "                print(\"亲爱的用户，感谢您的使用！\")\n",
    "                break\n",
    "    \n",
    "elif username in vipuser_data:\n",
    "    print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\" )\n",
    "    while True:\n",
    "        vipuser_count -= 1\n",
    "        if vipuser_count == -1:\n",
    "            print(\"尊贵的VIP用户，您今天的课程表查询次数已用完，欢迎明天再来，谢谢使用！\" )\n",
    "            break\n",
    "        else:\n",
    "            print(\"尊贵的VIP用户，是否要查询当前课程表，是 请回复“T”，否 请回复“F”\" )\n",
    "            vipchoice = input(\"您的选择是：\")\n",
    "            \n",
    "            if vipchoice == \"T\":\n",
    "                print()\n",
    "                import time \n",
    "                # 格式化时间\n",
    "                today = input(\"尊贵的VIP用户，请输入您要查询的星期（一~七）：\")\n",
    "                right_time = int(time.strftime(\"%H%M\")) # 这个用于后端页面\n",
    "                now = time.strftime(\"%A  %H:%M\") #这个用于前端页面\n",
    "                # 设置了提前半个钟（注：Hah == Half an hour）\n",
    "                Hah_Mon_class = int(('1035'))\n",
    "                Han_Mon_class = int(('1430'))\n",
    "                Hah_Tue_class = int(('1430'))\n",
    "                Hah_Wes_class = int(('1845'))\n",
    "                Hah_Thu_class = int(('1610'))\n",
    "                Hah_Fri_class = int(('1035'))\n",
    "                while True:\n",
    "                    if today == \"一\":\n",
    "                        if  1005< right_time < 1035:\n",
    "                            print (\"现在的时间是\",now)\n",
    "                            print(\"距离 羽毛球 @东区体育馆东面 还有\",Hah_Mon_class - right_time,\"分钟，请提前去教室，不要迟到了！\")\n",
    "                            print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                            print()\n",
    "                        \n",
    "                        elif 1005 > right_time or right_time > 1035:\n",
    "                            print (\"现在的时间是\",now)\n",
    "                            print (\"今天有两节课\")\n",
    "                            print (\"(10:35 - 12:00) 羽毛球 @东区体育馆东面 \")\n",
    "                            print (\"(14:30 - 16:50) Pyhton语言 @2实203\")\n",
    "                            print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                            print()\n",
    "\n",
    "                    elif today == \"一\":\n",
    "                        if 1400 < right_time < 1430:\n",
    "                            print (\"现在的时间是\",now)\n",
    "                            print(\"距离 Pyhton语言 @2实203 还有\",Hah_Mon_class - right_time,\"分钟，请提前去教室，不要迟到了！\")\n",
    "                            print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                            print()\n",
    "                        elif 1400 > right_time or right_time > 1430:\n",
    "                            print (\"现在的时间是\",now)\n",
    "                            print (\"今天有两节课\")\n",
    "                            print (\"(10:35 - 12:00) 羽毛球 @东区体育馆东面 \")\n",
    "                            print (\"(14:30 - 16:50) Pyhton语言 @2实203\")\n",
    "                            print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                            print()\n",
    "                        \n",
    "\n",
    "                    elif today == \"二\":\n",
    "                        if 1400 < right_time < 1430:\n",
    "                            print(\"现在的时间是\",now)\n",
    "                            print(\"距离 H5互动技术与应用 @3实308 还有\",Hah_Mon_class - right_time,\"分钟，请提前去教室，不要迟到了！\")\n",
    "                            print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                            print()\n",
    "                        elif 1400 > right_time or right_time > 1430:\n",
    "                            print (\"现在的时间是\",now)\n",
    "                            print (\"(14:30 - 15:55) H5互动技术与应用 @3实308\")\n",
    "                            print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                            print()\n",
    "\n",
    "                    elif today == \"三\":\n",
    "                        if 1815 < right_time < 1845:\n",
    "                            print(\"现在的时间是\",now)\n",
    "                            print(\"距离 创业基础（实践）@1-205 还有\",Hah_Mon_class - right_time,\"分钟，请提前去教室，不要迟到了！\")\n",
    "                            print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                            print()\n",
    "                        elif 1815 > right_time or right_time >  1845:\n",
    "                            print (\"现在的时间是\",now)\n",
    "                            print (\"(18:45 - 20:55) 创业基础（实践）@1-205\")\n",
    "                            print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                            print()\n",
    "\n",
    "                    elif today == \"四\":\n",
    "                        if 1545 < right_time < 1610:\n",
    "                            print(\"现在的时间是\",now)\n",
    "                            print(\"大学英语（三）A班 @10-205 还有\",Hah_Mon_class - right_time,\"分钟，请提前去教室，不要迟到了！\")\n",
    "                            print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                            print()\n",
    "                        elif 1545 > right_time or right_time > 1610:\n",
    "                            print (\"现在的时间是\",now)\n",
    "                            print (\"(16:10 - 17:35) 大学英语（三）A班 @10-205\")\n",
    "                            print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                            print()\n",
    "\n",
    "                    elif today == \"五\":\n",
    "                        if 1005 < right_time < 1035:\n",
    "                            print(\"现在的时间是\",now)\n",
    "                            print(\"距离 illustrator软件应用 @新综合楼612 还有\",Hah_Mon_class - right_time,\"分钟，请提前去教室，不要迟到了！\")\n",
    "                            print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                            print()\n",
    "                        elif 1005 > right_time > 1035:\n",
    "                            print (\"现在的时间是\",now)\n",
    "                            print (\"(10:35 - 12:00) illustrator软件应用 @新综合楼612)\")\n",
    "                            print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                            print()\n",
    "                            \n",
    "                    elif today == \"六\":\n",
    "                        print(\"现在的时间是\",now)\n",
    "                        print(\"尊贵的VIP用户，xxx提醒您，即使今天没课也要好好的写作业！\")\n",
    "                        print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                        print()\n",
    "                    elif today == \"七\":\n",
    "                        print(\"现在的时间是\",now)\n",
    "                        print(\"尊贵的VIP用户，xxx提醒您，即使今天没课也要好好的写作业！\")\n",
    "                        print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                        print()\n",
    "                    else :\n",
    "                        print (\"现在的时间是\",now)\n",
    "                        print (\"半个小时内没课\")\n",
    "                        print(\"尊贵的VIP用户，您今天还剩\",vipuser_count,\"次查询机会\")\n",
    "                        print()\n",
    "\n",
    "                    break\n",
    "            else:\n",
    "                print(\"尊贵的VIP用户，感谢您的使用！\")\n",
    "                break    \n",
    "else:\n",
    "    print()\n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c706a30c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
